<?php
defined('IN_MAIN') or exit('Invalid Access!');

function remove_invalid_item_from_sess_cart(){
global $vars;
$db=$vars["db"];
if(isset($_SESSION["cart"])){
 $pi=0;
 for($i=0,$t=count($_SESSION["cart"]);$i<$t;$i++){
  if(active_prod_refno_found(mysql_real_escape_string($_SESSION["cart"][$i]["refno"]))){
   $cart[$pi]=$_SESSION["cart"][$i];
   $pi++;
  }else{
   $errmsg.=replace_tag(__("Reference No. '<%ref%>'."), array("<%refno%>"=>$_SESSION["cart"][$i]["refno"]))."<br />\n";
  }
 }
 unset($_SESSION["cart"]);
 $_SESSION["cart"]=$cart;
}

return $errmsg? $errmsg : true;
}
?>